<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;

use cmf\controller\AdminBaseController;

class ListItemController extends AdminBaseController
{
    public function _initialize()
    {

    }

    //列表项列表
    public function index()
    {
        $tableName = $this->request->param('table_name','portal_post','trim');

        $list = db('listItem')->where('table_name',$tableName)->select();
        // pre($list,1);

        $this->assign('list', $list);
        $this->assign('table_name', $tableName);

        return $this->fetch();
    }

    //设置列表项
    public function settingPost(){
        if ($this->request->isPost()) {
            // $data = $this->request->param();
            $ids  = $this->request->param('ids/a');
            $tableName  = $this->request->param('table_name','','trim');

            if( !empty($tableName) ){
                //重置所有列表项为不显示
                db('listItem')->where('table_name',$tableName)->update(['status'=>0]);
                // die;
                //设置勾选的列表项为显示
                db('listItem')->where('id','in',$ids)->update(['status'=>1]);
            }

            // pre($ids,1);
        }
        // $this->success('设置成功');
    }
    

}
